<?php
class UserFacebook extends CActiveRecord
{
	
	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return "user_facebook";
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		
		return array(
			array('fb_id,fb_email,user_id', 'required'),
			
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
    	return array();
	}
	public static function forceLogin($binUserID, $remember = false) {
		$hexID = $binUserID;
		
		$identity = UUserIdentity::processAuth($hexID);
		
		$duration = 0;
		if ($remember) {
			$duration = 3600*24*30;
			//setcookie("rememberMe", 1, time() + $duration);
		}
			
		
		Yii::app()->user->login($identity, $duration);
		$user  = User::model()->findByPk($binUserID);
			
		if ($remember) {

		}
		
		
		return $user;
	}
	
}